import 'package:common_utils/common_utils.dart';
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBBaseMarQuee/ace_marquee.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBBaseRouter/YBApplication.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBColor/YBColor.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBImageStyle/YBImageStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBTextStyle/YBTextStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBWorkTaiModule/YBFenXiangHuKePage/YBBaseProvider/YBBaseProvider.dart';

class YBHomePageMainFPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[
          Container(
            child: Image.asset(YBImageStyle.getImagePath("homePage_banner"),fit: BoxFit.fitWidth,),
          ),
          Container(
            child: Padding(
                padding:EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20,top: YBTextStyle.adapterSize15),
                child: Container(
                  height: YBTextStyle.adapterSize52,
                  decoration: BoxDecoration(
                    border: Border.all(color:YBColor.homeBorderLineColor,width: 1),
                    borderRadius: BorderRadius.circular(YBTextStyle.adapterSize8),
                  ),
                  child: Padding(
                    padding: EdgeInsets.only(left:YBTextStyle.adapterSize12,right:YBTextStyle.adapterSize12),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: <Widget>[
                        Container(
                          child: SvgPicture.asset(YBImageStyle.getSVGPath("faxian_quanceng")),
                        ),
                        Container(
                          width: YBTextStyle.adapterSize8,
                        ),
                        Expanded(
                          child:ChangeNotifierProvider(
                              create: (context) => YBBaseProvider()..getReMenDataList(1, "kuaixun"),
                              child: Consumer<YBBaseProvider>(
                                  builder: (context,gonggaoList,child){
                                    Widget resultWidget;
                                    if (!ObjectUtil.isEmptyList(gonggaoList.reMenModelList)){
                                      if (gonggaoList.reMenModelList.length > 0) {
                                        resultWidget = ACEMarquee(
                                          children:gonggaoList.reMenModelList != null?gonggaoList.reMenModelList.map((e){
                                            return Container(
                                              alignment: Alignment.centerLeft,
                                              child:Padding(
                                                padding: EdgeInsets.only(left:YBTextStyle.adapterSize10,right:YBTextStyle.adapterSize10,top:YBTextStyle.adapterSize10,bottom:YBTextStyle.adapterSize10),
                                                child: Text(e.title??"",maxLines: 1,),
                                              ),
                                            );
                                          }).toList():null,
                                          direction: AxisDirection.up,
                                          duration: Duration(milliseconds: 2000),
                                        );
                                      } else {
                                        resultWidget = Container();
                                      }
                                    }
                                    return InkWell(
                                      child: Container(
                                        height: YBTextStyle.adapterSize44,
                                        child: resultWidget,
                                      ),
                                      onTap: ()=> YBApplication.router.navigateTo(context,'/workTaiPage/workTaiGonggaoPage?type=2'),
                                    );
                                  }
                              ),
                            ),
                        ),
                        Container(
                          width: YBTextStyle.adapterSize8,
                        ),
                        Container(
                          alignment: Alignment.centerRight,
                          child: SvgPicture.asset(YBImageStyle.getSVGPath("xiangyou_jiantou")),
                        ),
                      ],
                    ),
                  ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
